package cn.wolfcode.wolf2w.util;

import cn.wolfcode.wolf2w.excption.LogicExcption;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;

public class AssertUtil {

    private AssertUtil(){}

    //自定义断言工具类(参考Assert工具类)
    public static void hasLength(@Nullable String text, String message) {
        if (!StringUtils.hasLength(text)) {
            //设置抛出异常为自定义异常
            throw new LogicExcption(message);
        }
    }

    public static void isEquals(String str1, String str2,String msg) {
        if (str1==null||str2 == null){
            throw new LogicExcption("密码不能为空");
        }
        if (!str1.equals(str2)){
            throw new LogicExcption(msg);
        }
    }
}
